package com.myteam.fugaocrm.sqldb.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.myteam.fugaocrm.modle.FgPartnerProduct;

/**
 * 供应商产品/服务Mapper
 * @author BZX
 */
public interface FgPartnerProductMapper {
	/** 查询全部供应商公司 */
	@Select(
		"SELECT product.*,company.partner_company_name "
	  + "FROM fg_partner_product product "
	  + "LEFT JOIN fg_partner_company company ON company.partner_company_id = product.partner_company_id "
	  + "WHERE product.is_delete = 0")
	public List<FgPartnerProduct> all();
	
	/** 删除一个供应商公司 */
	@Select("update fg_partner_product set is_delete = 1 where partner_product_id = #{partnerProductId}")
	public void deleteOne(@Param("partnerProductId") Integer partnerProductId);
	
	/** 新增一个供应商公司 */
	@Select("insert into fg_partner_product(partner_company_id,partner_product_name,created_date,created_user) values(#{partnerCompanyId},#{partnerProductName},#{createdDate},#{createdUser})")
	public void insert(Map<String, Object> params);
	
	/** 修改一个供应商公司 */
	@Select("update fg_partner_product set partner_company_id=#{partnerCompanyId},partner_product_name=#{partnerProductName},modified_user=#{modifiedUser},modified_date=#{modifiedDate} where partner_product_id = #{partnerProductId}")
	public void update(Map<String, Object> params);
	
	/** 查询该供应商所有的产品/服务 */
	@Select("SELECT * FROM fg_partner_product WHERE is_delete = 0 AND partner_company_id = #{partnerCompanyId}")
	public List<FgPartnerProduct> selectList(Integer partnerProductId);
}
